package cn.iocoder.yudao.module.dine.config.controller.app;

import cn.iocoder.yudao.framework.business.basic.dao.query.CoreLambdaQueryWrapper;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.api.dine.vo.DineTimeRangeVO;
import cn.iocoder.yudao.module.dine.config.pojo.po.DineTimeRange;
import cn.iocoder.yudao.module.dine.config.service.app.AppDineTimeRangeService;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.annotation.security.PermitAll;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * <pre>
 * OOoO0OOoO0OOOooo0oOOOO0OOOOO0oooOO0ooOOO0Ooooo0OOOOo0ooooO0OOooo0Ooooo0OOOOO
 * 前端控制器
 * OOoO0OOoO0OOOooo0oOOOO0OOOOO0oooOO0ooOOO0Ooooo0OOOOo0ooooO0OOooo0Ooooo0OOOOO
 * </pre>
 *
 * @author 山野羡民（1032694760@qq.com）
 * @since 2025/09/07
 */
@Tag(name = "用户 APP - 点餐时段配置")
@RestController
@RequestMapping("/dine/config/time-range")
public class AppDineTimeRangeController {

    @Resource
    private AppDineTimeRangeService appDineTimeRangeService;


    @GetMapping("/list")
    @PermitAll
    public CommonResult<List<String>> getList(@RequestParam("categoryId") Long categoryId) {
        CoreLambdaQueryWrapper<DineTimeRange> wrapper = new CoreLambdaQueryWrapper<>();
        wrapper.eq(DineTimeRange::getCategoryId, categoryId);
        List<DineTimeRangeVO> list = appDineTimeRangeService.getList(wrapper);
        List<String> newList = new ArrayList<>();
        for (DineTimeRangeVO vo : list) {
            newList.addAll(vo.getTimeRange());
        }
        return CommonResult.success(newList);
    }

}
